#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Data.Common;
using System.Collections.Generic;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Metadata;


namespace WebForms	
{
	public partial class NorthwindEntityDiagrams : OpenAccessContext
	{
		private static string connectionStringName = @"NorthwindEntityDiagrams";
			
		private static BackendConfiguration backend = GetBackendConfiguration();
		
			
		private static MetadataSource metadataSource = XmlMetadataSource.FromAssemblyResource("NorthwindDiagram.rlinq");
	
		public NorthwindEntityDiagrams()
			:base(connectionStringName, backend, metadataSource)
		{ }
		
		public NorthwindEntityDiagrams(string connection)
			:base(connection, backend, metadataSource)
		{ }
	
		public NorthwindEntityDiagrams(BackendConfiguration backendConfiguration)
			:base(connectionStringName, backendConfiguration, metadataSource)
		{ }
			
		public NorthwindEntityDiagrams(string connection, MetadataSource metadataSource)
			:base(connection, backend, metadataSource)
		{ }
		
		public NorthwindEntityDiagrams(string connection, BackendConfiguration backendConfiguration, MetadataSource metadataSource)
			:base(connection, backendConfiguration, metadataSource)
		{ }
			
		public IQueryable<Customer> Customers 
		{
	    	get
	    	{
	        	return this.GetAll<Customer>();
	    	}
		}
		
		public IQueryable<Employee> Employees 
		{
	    	get
	    	{
	        	return this.GetAll<Employee>();
	    	}
		}
		
		public IQueryable<Order> Orders 
		{
	    	get
	    	{
	        	return this.GetAll<Order>();
	    	}
		}
		
		public IQueryable<OrderDetail> OrderDetails 
		{
	    	get
	    	{
	        	return this.GetAll<OrderDetail>();
	    	}
		}
		
		public object[] TenMostExpensiveProducts()
		{
			object[] queryResult = this.ExecuteStoredProcedure<object>("'Ten Most Expensive Products' ", null );
	        
	    	return queryResult;
		}
		
		public object[] SalesByCategory(string ordYear, string categoryName)
		{
			SqlParameter parameterOrdYear = new SqlParameter("OrdYear", OpenAccessType.Varchar);
			SqlParameter parameterCategoryName = new SqlParameter("CategoryName", OpenAccessType.Varchar);
		
			List<SqlParameter> sqlParameters = new List<SqlParameter>()
			{
				parameterOrdYear, parameterCategoryName
			};
			
			object[] queryResult = this.ExecuteStoredProcedure<object>("'SalesByCategory' ?,?", sqlParameters, ordYear, categoryName);
	        
	    	return queryResult;
		}
		
		public object[] SalesByYear(DateTime? endingDate, DateTime? beginningDate)
		{
			SqlParameter parameterEndingDate = new SqlParameter("Ending_Date", OpenAccessType.DateTime);
			SqlParameter parameterBeginningDate = new SqlParameter("Beginning_Date", OpenAccessType.DateTime);
		
			List<SqlParameter> sqlParameters = new List<SqlParameter>()
			{
				parameterEndingDate, parameterBeginningDate
			};
			
			object[] queryResult = this.ExecuteStoredProcedure<object>("'Sales by Year' ?,?", sqlParameters, endingDate, beginningDate);
	        
	    	return queryResult;
		}
		
		public object[] OrdersPaged(int? pagestart, int? pagesize, ref int? numresults)
		{
			SqlParameter parameterPagestart = new SqlParameter("pagestart", OpenAccessType.Int32);
			SqlParameter parameterPagesize = new SqlParameter("pagesize", OpenAccessType.Int32);
			SqlParameter parameterNumresults = new SqlParameter("numresults", OpenAccessType.Int32, ParameterMode.InOut);
	        IDictionary<string,object> outParameterMap = new Dictionary<string, object>();
	        	
			List<SqlParameter> sqlParameters = new List<SqlParameter>()
			{
				parameterPagestart, parameterPagesize, parameterNumresults
			};
			
			object[] queryResult = this.ExecuteStoredProcedure<object>("'Orders_Paged' ?,?,?", sqlParameters,out outParameterMap,  pagestart, pagesize, numresults);
	        numresults = (int?) outParameterMap["numresults"];

	    	return queryResult;
		}
		
		public object[] EmployeeSalesByCountry(DateTime? endingDate, DateTime? beginningDate)
		{
			SqlParameter parameterEndingDate = new SqlParameter("Ending_Date", OpenAccessType.DateTime);
			SqlParameter parameterBeginningDate = new SqlParameter("Beginning_Date", OpenAccessType.DateTime);
		
			List<SqlParameter> sqlParameters = new List<SqlParameter>()
			{
				parameterEndingDate, parameterBeginningDate
			};
			
			object[] queryResult = this.ExecuteStoredProcedure<object>("'Employee Sales by Country' ?,?", sqlParameters, endingDate, beginningDate);
	        
	    	return queryResult;
		}
		
		public object[] CustOrdersOrders(string customerID)
		{
			SqlParameter parameterCustomerID = new SqlParameter("CustomerID", OpenAccessType.Character);
		
			List<SqlParameter> sqlParameters = new List<SqlParameter>()
			{
				parameterCustomerID
			};
			
			object[] queryResult = this.ExecuteStoredProcedure<object>("'CustOrdersOrders' ?", sqlParameters, customerID);
	        
	    	return queryResult;
		}
		
		public object[] CustOrdersDetail(int? orderID)
		{
			SqlParameter parameterOrderID = new SqlParameter("OrderID", OpenAccessType.Int32);
		
			List<SqlParameter> sqlParameters = new List<SqlParameter>()
			{
				parameterOrderID
			};
			
			object[] queryResult = this.ExecuteStoredProcedure<object>("'CustOrdersDetail' ?", sqlParameters, orderID);
	        
	    	return queryResult;
		}
		
		public object[] CustOrderHist(string customerID)
		{
			SqlParameter parameterCustomerID = new SqlParameter("CustomerID", OpenAccessType.Character);
		
			List<SqlParameter> sqlParameters = new List<SqlParameter>()
			{
				parameterCustomerID
			};
			
			object[] queryResult = this.ExecuteStoredProcedure<object>("'CustOrderHist' ?", sqlParameters, customerID);
	        
	    	return queryResult;
		}
		
		public static BackendConfiguration GetBackendConfiguration()
		{
			BackendConfiguration backend = new BackendConfiguration();
			backend.Backend = "mssql";
			return backend;
		}
	}
}
#pragma warning restore 1591

